home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 April: Mac OS SDK / Dev.CD Apr 97 SDK1.toast / Development Kits (Disc 1) / Interfaces&Libraries / Interfaces / PInterfaces / CursorCtl.p < prev    next >
Encoding:
Text File  |  1996-09-18  |  5.5 KB  |  139 lines  |  [TEXT/MPS ]

  1. {
  2.     File:        CursorCtl.p
  3.  
  4.      Copyright:    © 1984-1995 by Apple Computer, Inc.
  5.                  All rights reserved.
  6.  
  7.      Version:    Universal Interfaces 2.0a3  ETO #16, MPW prerelease. Jan 2, 1995
  8.  
  9.      Bugs?:        If you find a problem with this file, send the file and version
  10.                  information (from above) and the problem description to:
  11.  
  12.                      Internet:    apple.bugs@applelink.apple.com
  13.                      AppleLink:    APPLE.BUGS
  14.  
  15.     07/21/95    DGD    Removing LibExport directives.  ToolLibs is a static library
  16.                                 in all environments.
  17. }
  18.  
  19. {$IFC UNDEFINED UsingIncludes}
  20. {$SETC UsingIncludes := 0}
  21. {$ENDC}
  22.  
  23. {$IFC NOT UsingIncludes}
  24.     UNIT CursorCtl;
  25.     INTERFACE
  26. {$ENDC}
  27.  
  28. {$IFC UNDEFINED __USINGCURSORCTL__}
  29. {$SETC __USINGCURSORCTL__ := 1}
  30.  
  31. {$PUSH}
  32. {$ALIGN MAC68K}
  33.  
  34. TYPE
  35.  
  36. { Kinds of cursor supported by CursorCtl }
  37. Cursors = (HIDDEN_CURSOR,I_BEAM_CURSOR,CROSS_CURSOR,PLUS_CURSOR,WATCH_CURSOR,
  38.     ARROW_CURSOR);
  39.  
  40. acurPtr = ^Acur;
  41. acurHandle = ^acurPtr;
  42. Acur = RECORD
  43.     n: INTEGER;         {Number of cursors ("frames of film")}
  44.     index: INTEGER;     { Next frame to show <for internal use>}
  45.     frame1: INTEGER;    {'CURS' resource id for frame #1}
  46.     fill1: INTEGER;     {<for internal use>}
  47.     frame2: INTEGER;    {'CURS' resource id for frame #2}
  48.     fill2: INTEGER;     {<for internal use>}
  49.     frameN: INTEGER;    {'CURS' resource id for frame #N}
  50.     fillN: INTEGER;     {<for internal use>}
  51.     END;
  52.  
  53.  
  54.  
  55. PROCEDURE InitCursorCtl(newCursors: UNIV acurHandle);
  56. { Initialize the CursorCtl unit. This should be called once prior to calling
  57. RotateCursor or SpinCursor. It need not be called if only Hide_Cursor or
  58. Show_Cursor are used. If NewCursors is NULL, InitCursorCtl loads in the
  59. 'acur' resource and the 'CURS' resources specified by the 'acur' resource
  60. ids.  If any of the resources cannot be loaded, the cursor will not be
  61. changed.
  62.  
  63. The 'acur' resource is assumed to either be in the currently running tool or
  64. application, or the MPW Shell for a tool, or in the System file.  The 'acur'
  65. resource id must be 0 for a tool or application, 1 for the Shell, and 2 for
  66. the System file.
  67.  
  68. If NewCursors is not NULL, it is ASSUMED to be a handle to an 'acur' formatted
  69. resource designated by the caller and it will be used instead of doing a
  70. GetResource on 'acur'. Note, if RotateCursor or SpinCursor are called without
  71. calling InitCursorCtl, then RotateCursor and SpinCursor will do the call for
  72. the user the first time it is called.  However, the possible disadvantage of
  73. using this technique is that the resource memory allocated may have
  74. undesirable affect (fragmentation?) on the application. Using InitCursorCtl
  75. has the advantage of causing the allocation at a specific time determined by
  76. the user.
  77.  
  78. Caution: InitCursorCtl MODIFIES the 'acur' resource in memory.    Specifically,
  79. it changes each FrameN/fillN integer pair to a handle to the corresponding
  80. 'CURS' resource also in memory.  Thus if NewCursors is not NULL when
  81. InitCursorCtl is called, the caller must guarantee NewCursors always points to
  82. a "fresh" copy of an 'acur' resource.  This need only be of concern to a
  83. caller who wants to repeatly use multiple 'acur' resources during execution of
  84. their programs.
  85.  }
  86.  
  87. PROCEDURE RotateCursor(counter: LONGINT);
  88. { RotateCursor is called to rotate the "I am active" "beach ball" cursor, or to
  89. animate whatever sequence of cursors set up by InitCursorCtl. The next cursor
  90. ("frame") is used when Counter % 32 = 0 (Counter is some kind of incrementing
  91. or decrementing index maintained by the caller). A positive counter sequences
  92. forward through the cursors (e.g., it rotates the "beach ball" cursor
  93. clockwise), and a negative cursor sequences through the cursors backwards
  94. (e.g., it rotates the "beach ball" cursor counterclockwise).  Note,
  95. RotateCursor just does a Mac SetCursor call for the proper cursor picture.
  96.   It is assumed the cursor is visible from a prior Show_Cursor call.
  97.  }
  98.  
  99. PROCEDURE SpinCursor(increment: INTEGER);
  100. { SpinCursor is similar in function to RotateCursor, except that instead of
  101. passing a counter, an Increment is passed an added to a counter maintained
  102. here.  SpinCursor is provided for those users who do not happen to have a
  103. convenient counter handy but still want to use the spinning "beach ball"
  104. cursor, or any sequence of cursors set up by InitCursorCtl.  A positive 
  105. increment sequences forward through the curos (rotating the "beach ball"
  106. cursor clockwise), and a negative increment sequences backward through the
  107. cursors (rotating the "beach ball" cursor counter-clockwise).  A zero value
  108. for the increment resets the counter to zero.  Note, it is the increment, and
  109. not the value of the counter that determines the sequencing direction of the
  110. cursor (and hence the spin direction of the "beach ball" cursor).
  111.  }
  112.  
  113. PROCEDURE Hide_Cursor;
  114. { Hide the cursor if it is showing.This is this unit's call to the Mac
  115. HideCursor routine.Thus the Mac cursor level is decremented by one when this
  116. routine is called.
  117.  }
  118.  
  119. PROCEDURE Show_Cursor(cursorKind: Cursors);
  120. { Increment the cursor level, which may have been decremented by Hide_Cursor,
  121. and display the specified cursor if the level becomes 0 (it is never
  122. incremented beyond 0).The CursorKind is the kind of cursor to show.  It is
  123. one of the values HIDDEN_CURSOR, I_BEAM_CURSOR, CROSS_CURSOR, PLUS_CURSOR,
  124. WATCH_CURSOR, and ARROW_CURSOR. Except for HIDDEN_CURSOR, a Mac SetCursor is
  125. done for the specified cursor prior to doing a ShowCursor.    HIDDEN_CURSOR just
  126. causes a ShowCursor call.  Note, ARROW_CURSOR will only work correctly if
  127. there is already a grafPort set up pointed to by 0(A5).
  128.  }
  129.  
  130. {$ALIGN RESET}
  131. {$POP}
  132.  
  133. {$ENDC}    { __USINGCURSORCTL__ }
  134.  
  135. {$IFC NOT UsingIncludes}
  136.     END.
  137. {$ENDC}
  138.  
  139.